/*
 *  Copyright 2005 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.webapp.form.questionnaire;

import com.blandware.atleap.webapp.form.BaseForm;

import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;

import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>Form for filling a questionnaire.</p>
 * <p><a href="FillQuestionnaireForm.java.html"><i>View source</i></a></p>
 *
 * @author Roman Puchkovskiy <a href="mailto:roman.puchkovskiy@blandware.com">
 *         &lt;roman.puchkovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.1 $ $Date: 2006/05/18 16:49:07 $
 * @struts.form name="fillQuestionnaireForm"
 */
public class FillQuestionnaireForm extends BaseForm implements Serializable {

    /**
     * ID of questionnaire for this form
     */
    protected Long id;

    /**
     * Map that contains questions fields of textual type
     */
    protected Map textQuestionMap = new HashMap();

    /**
     * Map that contains questions fields for integer values
     */
    protected Map intQuestionMap = new HashMap();

    /**
     * Map that contains questions fields for multi integer values
     */
    protected Map multiIntQuestionMap = new HashMap();

    /**
     * Map that contains question fields for checkboxes
     */
    protected Map checkboxQuestionMap = new HashMap();

    /**
     * Returns questionnaire ID.
     *
     * @return questionnaire ID
     */
    public Long getId() {
        return id;
    }

    /**
     * Sets questionnaire ID.
     *
     * @param id ID to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * Returns textual questions map.
     *
     * @return textual questions map
     */
    public Map getTextQuestionMap() {
        return textQuestionMap;
    }

    /**
     * Sets textual question map.
     *
     * @param textQuestionMap map to set
     */
    public void setTextQuestionMap(Map textQuestionMap) {
        this.textQuestionMap = textQuestionMap;
    }

    /**
     * Returns value stored under given ID in textual question map.
     *
     * @param id value ID
     * @return a value
     */
    public String getTextQuestion(String id) {
        return (String) textQuestionMap.get(id);
    }

    /**
     * Sets a value for some ID in a textual question map.
     *
     * @param id valueID
     * @param value value itself
     */
    public void setTextQuestion(String id, String value) {
        textQuestionMap.put(id, value);
    }

    /**
     * Returns a map with 'integer' questions.
     *
     * @return 'integer' question map
     */
    public Map getIntQuestionMap() {
        return intQuestionMap;
    }

    /**
     * Sets a map with 'integer' questions.
     *
     * @param intQuestionMap map to set
     */
    public void setIntQuestionMap(Map intQuestionMap) {
        this.intQuestionMap = intQuestionMap;
    }

    /**
     * Returns value stored under given ID in an 'integer' question map.
     *
     * @param id value ID
     * @return a value
     */
    public Long getIntQuestion(String id) {
        return (Long) intQuestionMap.get(id);
    }

    /**
     * Sets a value for some ID in an 'integer' question map.
     *
     * @param id valueID
     * @param value value itself
     */
    public void setIntQuestion(String id, Long value) {
        intQuestionMap.put(id, value);
    }

    /**
     * Returns a map with 'multi-integer' questions.
     *
     * @return 'multi-integer' question map
     */
    public Map getMultiIntQuestionMap() {
        return multiIntQuestionMap;
    }

    /**
     * Sets a map with 'multi-integer' questions.
     *
     * @param multiIntQuestionMap map to set
     */
    public void setMultiIntQuestionMap(Map multiIntQuestionMap) {
        this.multiIntQuestionMap = multiIntQuestionMap;
    }

    /**
     * Returns value stored under given ID in a 'multi-integer' question map.
     *
     * @param id value ID
     * @return a value
     */
    public Long[] getMultiIntQuestion(String id) {
        return (Long[]) multiIntQuestionMap.get(id);
    }

    /**
     * Sets a value for some ID in a 'multi-integer' question map.
     *
     * @param id valueID
     * @param value value itself
     */
    public void setMultiIntQuestion(String id, Long[] value) {
        multiIntQuestionMap.put(id, value);
    }

    /**
     * Returns a checkbox question map.
     *
     * @return checkbox question map
     */
    public Map getCheckboxQuestionMap() {
        return checkboxQuestionMap;
    }

    /**
     * Sets a checkbox question map.
     *
     * @param checkboxQuestionMap map to set
     */
    public void setCheckboxQuestionMap(Map checkboxQuestionMap) {
        this.checkboxQuestionMap = checkboxQuestionMap;
    }

    /**
     * Returns value stored under given ID in a checkbox question map.
     *
     * @param id value ID
     * @return a value
     */
    public String getCheckboxQuestion(String id) {
        return (String) checkboxQuestionMap.get(id);
    }

    /**
     * Sets a value for some ID in a checkbox question map.
     *
     * @param id valueID
     * @param value value itself
     */
    public void setCheckboxQuestion(String id, String value) {
        checkboxQuestionMap.put(id, value);
    }

	/**
	 * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
        this.id = null;
		this.textQuestionMap = new HashMap();
        this.intQuestionMap = new HashMap();
        this.multiIntQuestionMap = new HashMap();
        this.checkboxQuestionMap = new HashMap();
	}
}
